package com.ruicar.afs.cloud.product.controller;

import com.ruicar.afs.cloud.common.core.util.IResponse;
import com.ruicar.afs.cloud.product.condition.ProductPlanCondition;
import com.ruicar.afs.cloud.product.service.ProductPlanAtomService;
import com.ruicar.afs.cloud.product.service.ProductUpdateAtomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author changyu.gui
 * @version 1.0
 * @date 2020/5/14 17:51
 */
@Slf4j
@RestController
@AllArgsConstructor
@Api("产品方案数据接口")
@RequestMapping("/productPlanData")
public class ProductPlanDataController {

    private final ProductPlanAtomService productPlanAtomService;
    private final ProductUpdateAtomService productUpdateAtomService;

    @PostMapping("/getPlanInfo")
    @ApiOperation(value = "获取产品方案数据")
    public IResponse getPlanInfo(ProductPlanCondition planCondition) {
        Map<String, Object> map = productPlanAtomService.getProductPlanDataInfo(planCondition.getId(), planCondition.getAtomShowType(), planCondition.getNotAtomShowType());
        return new IResponse<Map<String, Object>>().setData(map);
    }

    @PostMapping("/getUpdateInfo")
    @ApiOperation(value = "获取产品修改数据")
    public IResponse getUpdateInfo(ProductPlanCondition planCondition) {
        Map map = productUpdateAtomService.getProductPlanDataInfo(planCondition);
        return new IResponse<Map<String, Object>>().setData(map);
    }

}
